//
//  GHPushVC.m
//  VideoPic
//
//  Created by GH on 16/3/29.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "GHPushVC.h"
#import <YYWebImage.h>

@interface GHPushVC ()<UIGestureRecognizerDelegate>


@end

@implementation GHPushVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.view.backgroundColor = [UIColor blackColor];
//    if (self.height > 400) {
//        self.height = 350;
//    }
    
    UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    [self.view addSubview:scroll];
    scroll.contentSize = CGSizeMake(self.view.frame.size.width, self.view.frame.size.height);
    
    self.image = [[UIImageView alloc] initWithFrame:CGRectMake(self.x, self.y, self.view.frame.size.width - 40, self.height)];
    
    [scroll addSubview:self.image];
    self.image.backgroundColor = [UIColor redColor];
    
    self.image.yy_imageURL = [NSURL URLWithString:self.url];
    
    UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleClick:)];
//    tapGesture.numberOfTouchesRequired = 1;
    [scroll addGestureRecognizer:tapGesture];

    
    
    [UIView animateWithDuration:0.6 animations:^{
        scroll.contentSize  = CGSizeMake(self.view.frame.size.width, self.heightNew);
        self.image.frame = CGRectMake(10, 10, self.view.frame.size.width - 20, self.heightNew);
        
        
    }];
    
    
}

- (void)handleClick:(UITapGestureRecognizer *)tap {
    
    [UIView animateWithDuration:0.3 animations:^{
        self.image.frame = CGRectMake(self.x, self.y, self.view.frame.size.width - 40, self.height);
    } completion:^(BOOL finished) {
        
        [[NSNotificationCenter defaultCenter] postNotificationName:@"tabBarhidden" object:nil];
        self.navigationController.navigationBar.hidden = NO;
        [self.navigationController popViewControllerAnimated:NO];
        
    }];
    
    

}


- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {
    
    return YES;
}



- (void)dealloc {

    NSLog(@"移除");
    [[NSNotificationCenter defaultCenter] removeObserver:self name:@"tabBarhidden" object:nil];

}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
